home *** CD-ROM | disk | FTP | other *** search
/ C/C++ Users Group Library 1996 July / C-C++ Users Group Library July 1996.iso / vol_300 / 395_01 / avl / stckallc.h < prev    next >
Encoding:
C/C++ Source or Header  |  1993-08-21  |  1.4 KB  |  62 lines

  1. /* header file for the stack allocation package. */
  2.  
  3. #if !defined(STCKALLC_H)
  4. #define STCKALLC_H
  5.  
  6. /* get definition of size_t */
  7. #include <stdlib.h>
  8.  
  9. /* allocation stack.  all fields are private */
  10. typedef struct
  11.   {
  12.     /* number of ALIGN_TYPEs in each allocation element */
  13.     size_t n_units_in_element;
  14.     /* pointer to linked list of blocks */
  15.     void *block_list;
  16.     /* index of next free ALIGN_TYPE in current block */
  17.     size_t free;
  18.     /* number of ALIGN_TYPEs in each block */
  19.     size_t n_units_in_block;
  20.   }
  21. ALLOC_STACK;
  22.  
  23. /* initialize allocation stack */
  24. void init_alloc_stack
  25.   (
  26.     /* pointer to allocation stack to initialize */
  27.     ALLOC_STACK *as,
  28.     /* sizeof elements to be allocated */
  29.     size_t elem_size
  30.   );
  31.  
  32. /* allocate an element from the allocation stack.  returns null if
  33.    insufficient memory available */
  34. void *get_alloc_stack
  35.   (
  36.     /* pointer to allocation stack */
  37.     ALLOC_STACK *as
  38.   ); 
  39.  
  40. /* return address of last element allocated */
  41. void *look_alloc_stack
  42.   (
  43.     /* pointer to allocation stack */
  44.     const ALLOC_STACK *as
  45.   ); 
  46.  
  47. /* free last element allocated */
  48. void free_alloc_stack
  49.   (
  50.     /* pointer to allocation stack */
  51.     ALLOC_STACK *as
  52.   ); 
  53.  
  54. /* free all elements allocated */
  55. void clear_alloc_stack
  56.   (
  57.     /* pointer to allocation stack */
  58.     ALLOC_STACK *as
  59.   ); 
  60.  
  61. #endif
  62.